package com.health.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 封装返回结果
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {
    private boolean flag;//执行结果，true为执行成功 false为执行失败
    private String message;//返回结果信息，主要用于页面提示信息
    private Object data;//返回数据

   /* public Result(boolean flag, String message) {
        super();
        this.flag = flag;
        this.message = message;
    }

    public Result(boolean flag, String message, Object data) {
        this.flag = flag;
        this.message = message;
        this.data = data;
    }*/

    public static Result success(Object data) {
        return new Result(true, "成功", data);
    }

    public static Result success(String message) {
        return new Result(true, message, null);
    }

    public static Result success(Object data, String message) {
        return new Result(true, message, data);
    }

    public static Result success() {
        return new Result(true, "成功", null);
    }


    public static Result error(String message) {
        return new Result(false, message, null);
    }

    public static Result error() {
        return new Result(false, "系统出现异常,请重试", null);
    }


}
